package com.ithzl.capacity.pojo.dto;

import com.ithzl.capacity.pojo.EntryForm;
import com.ithzl.capacity.pojo.TeamQualification;
import com.ithzl.capacity.pojo.TeamWorks;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Data
public class EntryFormDTO {
    private int entryFormId;
    private int userId;
    private String worksName ;
    private String competitionGroup ;
    private String school ;
    private String team ;
    private List<TeamQualification> teamQualificationList;
    MultipartFile formMF;//参赛报名表
    MultipartFile messageMF;//信息公示表
    private String phoneNumber ;
    private List<TeamWorksDTO> teamWorksDTOList;//团队课堂实录
    MultipartFile teachingPlanMF;//教案
    MultipartFile practiceReportMF;//教学实施报告
    MultipartFile trainingProgramMF;//人才培养方案
    MultipartFile standardDateMF;//课程标准
    MultipartFile explainDateMF;//教材选用说明
    private int submit;
    private double score;

    public EntryFormDTO() {
    }

    public EntryForm transition() throws IOException {
        EntryForm entryForm=new EntryForm();
        entryForm.setEntryFormId(entryFormId);
        entryForm.setUserId(userId);
        entryForm.setWorksName(worksName);
        entryForm.setCompetitionGroup(competitionGroup);
        entryForm.setSchool(school);
        entryForm.setTeam(team);
        entryForm.setTeamQualificationList(teamQualificationList);
        entryForm.setFormDate(formMF.getBytes());
        entryForm.setFormName(formMF.getOriginalFilename());
        entryForm.setFormType(formMF.getContentType());
        entryForm.setMessageDate(messageMF.getBytes()) ;//信息公示表
        entryForm.setMessageName(messageMF.getOriginalFilename()) ;
        entryForm.setMessageType(messageMF.getContentType()) ;
        entryForm.setPhoneNumber(phoneNumber) ;
        List<TeamWorks> teamWorks=new ArrayList<>();
        for (TeamWorksDTO teamWorksDTO:teamWorksDTOList){
            TeamWorks teamWorks1=new TeamWorks();
            teamWorks1.setTeamNumber(teamWorksDTO.getTeamNumber());
            teamWorks1.setWorks(teamWorksDTO.getWorksMF().getBytes());
            teamWorks1.setWorksName(teamWorksDTO.getWorksMF().getOriginalFilename());
            teamWorks1.setWorksType(teamWorksDTO.getWorksMF().getContentType());
            teamWorks.add(teamWorks1);
        }
        entryForm.setTeamWorksList(teamWorks);//团队课堂实录
        entryForm.setTeachingPlanDate(teachingPlanMF.getBytes()) ;//教案
        entryForm.setTeachingPlanName(teachingPlanMF.getOriginalFilename()) ;
        entryForm.setTeachingPlanType(teachingPlanMF.getContentType()) ;
        entryForm.setPracticeReportDate(practiceReportMF.getBytes());//教学实施报告
        entryForm.setPracticeReportName(practiceReportMF.getOriginalFilename());
        entryForm.setPracticeReportType(practiceReportMF.getContentType()) ;
        entryForm.setTrainingProgramDate(trainingProgramMF.getBytes());//人才培养方案
        entryForm.setTrainingProgramName(trainingProgramMF.getOriginalFilename());
        entryForm.setTrainingProgramType(trainingProgramMF.getContentType());
        entryForm.setStandardDate(standardDateMF.getBytes());//课程标准
        entryForm.setStandardName(standardDateMF.getOriginalFilename());
        entryForm.setStandardType(standardDateMF.getContentType());
        entryForm.setExplainDate(explainDateMF.getBytes());//教材选用说明
        entryForm.setExplainName(explainDateMF.getOriginalFilename());
        entryForm.setExplainType(explainDateMF.getContentType());
        entryForm.setSubmit(submit);
        entryForm.setScore(score);
        return entryForm;
    }
}
